package com.huqu.daoimpl;

import java.sql.Types;
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.huqu.basedao.QbDaoSupport;
import com.huqu.basedao.QbEntityMapper;
import com.huqu.basedao.QbSqlParam;
import com.huqu.dao.Q100Dao;
import com.huqu.entities.Q100;
import com.huqu.utils.ApplicationConstant;
import com.huqu.utils.SqlNames;

@Repository(value = ApplicationConstant.REPOSITORY_NAME_Q100)
@Scope("prototype")
public class Q100DaoImpl extends QbDaoSupport implements Q100Dao {


	@Override
	public int Checklogin(String username, String password) {
		// TODO Auto-generated method stub
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.CHAR, username));
		listParams.add(new QbSqlParam(Types.CHAR, password));
		setQueenBListSqlParams(listParams);
		// set fuction
		setQbFunction(true);
		setQbFunctionReturnType(Types.INTEGER);
		setQueenBSqlName(SqlNames.CHECKLOGIN);
		executeQueenBQuery();
		int re = Integer.parseInt(getObjectReturnFunction().toString());
		return re;
	}

	@Override
	public List<Q100> ListOfTabQ100(int offset, int limit) {
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.INTEGER, offset));
		listParams.add(new QbSqlParam(Types.INTEGER, limit));
		setQueenBListSqlParams(listParams);
		// set sql name
		setQueenBSqlName(SqlNames.LISTOFTABQ100);
		// set row mapper
		setQueenBEntityMapper(new QbEntityMapper(Q100.class));
		executeQueenBQuery();
		List<Q100> listQ100 = (List<Q100>) getListReturn();
		return listQ100;
	}

}
